package com.Lab427.workflow.pojo;

import com.Lab427.workflow.common.enums.NodeType;
import com.Lab427.workflow.service.DAGExecutor.NodeService;
import com.Lab427.workflow.service.DAGExecutor.NodeServiceDispatcher;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.w3c.dom.Node;

import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;

@Data
public class WorkNode implements Callable<String> {

    private final  NodeServiceDispatcher dispatcher;

    private final Long id;
    private final String name;

    private final  NodeType type;

    Map<String, Object> config;
    private final List<Long> dependencies;

    public WorkNode(NodeServiceDispatcher dispatcher, Long id, String name, NodeType type, Map config, List<Long> dependencies) {
        this.dispatcher = dispatcher;
        this.id = id;
        this.name = name;
        this.type = type;
        this.config = config;
        this.dependencies = dependencies;
    }


    @Override
    public String call() throws Exception {
        System.out.println("处理节点 "+id);
        return dispatcher.execute(this.type,config);
    }
}